/**
 * @author WRP
 */

// DIRECTIVE PARA AUMENTAR O TAMANHO DA TELA
angular.module('resize',[]).directive('resizeMensagem', function() {
		
    return {
        restrict: 'AC',
        link: function (scope, element, attrs) {
        	
            element.css({
            	'position':'absolute',
            	 'width': '450',
            	 'height':'100px',
            	'left':'50%',
                'margin-left': '-225px',
                'margin-top':'40%' 
            });
        }
  }
});


// FACTORY COM AS FUNÇÕES 
angular.module('download',['ui.bootstrap','resize']).factory('download',function ($modal) {
	
	download          = {};
	
	var modalDownload ={};
	
	download.abrir   = function(url){
		 
		  modalDownload = $modal.open({
		      templateUrl: 'templanteDownalod',   
		      controller: MyCtrlDownload,
		      resolve: {
				    url: function(){
				        return url
				    }
			  }
		 });	
	};
	
	download.fechar   = function(){
		 modalDownload.close();	
	};
	
	return  download;
});


// CONTROLE 
var MyCtrlDownload = function ($scope,url,download){
	      
	$scope.fecharDownload = function(){
		download.fechar();
	};
	
	$scope.visualizar = function(){
		window.open(url, "_blank");
	};
	
	$scope.baixar = function(){
		window.open(url,'Download');  
	};
};



